/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.dao;

import hibernate.entity.MessageType;
import java.util.List;
import util.HibernateUtil;

/**
 *
 * @author NDH
 */
public class MessageTypeDAO extends AbstractDAO{
    public List< MessageType> readAll(){
        session = HibernateUtil.getSessionFactory().openSession();
        query = session.createQuery("from  MessageType");
        return query.list();
    }
    
    public  MessageType readByID(int id){
        query = session.createQuery("from  MessageType where typeId = :id");
        query.setParameter("id", id);
        try {
            return ( MessageType) query.list().get(0);
        } catch (Exception e) {
            return null;
        }
        
    }
}
